home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Audio / Patchmix / XWindowsSource / nutree.c < prev    next >
C/C++ Source or Header  |  1992-03-28  |  1KB  |  89 lines

  1. static char rcsid[] = "$Header: nutree.c,v 1.2 90/10/11 10:31:40 mara Exp $";
  2.  
  3. /* 
  4.  *  nutree.c
  5.  *
  6.  *  Written by Mara Helmuth
  7.  *
  8.  *  Description: N-ary tree classes for Cmix X graphical interface
  9.  * 
  10.  *  $Log:    nutree.c,v $
  11.  * Revision 1.2  90/10/11  10:31:40  mara
  12.  * *** empty log message ***
  13.  * 
  14.  * Revision 1.1  90/08/27  17:09:21  mara
  15.  * Initial revision
  16.  * 
  17.  * 
  18.  */
  19.  
  20. #include "plus.h"
  21.  
  22. tree::tree(int s, int out_ugen)
  23. {
  24.     root = 0;
  25.     size = s;
  26.  
  27.     root = new t_node;
  28.     root->contents = out_ugen;
  29.     insert(root);
  30. }
  31.  
  32. void tree::insert(t_node* parent)
  33. {
  34.     t_node* child;
  35.  
  36.     child = get_child(parent);
  37.  
  38.     if(child)
  39.         insert(child);
  40.     else
  41.         ;
  42.  
  43.     /* if(child == lastchild)
  44.         printf("now do nutree ugen %d\n",parent->contents);
  45. */
  46.     // process the ugen
  47. }
  48.  
  49. t_node* tree::get_child(t_node* p)
  50. {
  51.     t_node* child = new t_node;
  52.     switch(ugen[p->contents].type) {
  53.         case OSCIL: {
  54.             switch(p->index) {
  55.                 case 0: {
  56.                     child->contents = ugen[p->contents].oscil->amp->in_ugen;
  57.                     return child;
  58.                     break;
  59.                 }
  60.             
  61.             break;
  62.             }
  63.         }
  64.     }
  65.     return 0;
  66.  
  67. }
  68.  
  69. void tree::clear(t_node* n,int first)
  70. {
  71. /*
  72.     t_node* current;
  73.     if (first) {
  74.         current = root;
  75.         first = 0;
  76.         root = 0;
  77.     }
  78.     else
  79.         current = n;
  80.     if (current != 0) {
  81.         clear(current -> left,first);
  82.         clear(current -> right,first);
  83.         if (current) {
  84.             delete current;
  85.         }
  86.     }
  87. */
  88. }
  89.